<template>
    <el-form ref="ruleFormRef" style="width: 100%" :model="ruleForm" label-width="auto" class="demo-ruleForm" :size="formSize" status-icon >
        <el-form-item label="类型" prop="type">
            <el-text >{{ ruleForm.type }}</el-text>
        </el-form-item>
        <el-form-item label="描述" prop="title">
            <el-text >{{ ruleForm.title }}</el-text>
        </el-form-item>
        <el-form-item label="措施" prop="measure">
            <el-text>{{ ruleForm.measure }}</el-text>
        </el-form-item>
    </el-form>
    <el-divider />
</template>
  
<script lang="ts" setup>
import { ref,watch } from 'vue'
import { type ComponentSize, type FormInstance} from 'element-plus'
import http from '../util/request';
const type = ref<number>(0)
interface RuleForm {
    id: number
    project_id:number
    person_id:number
    user_id:number
    title: string
    measure: string
    effectiveness:string
    start_date: string
    end_date: string
    status: number
    type:string
}
const formSize = ref<ComponentSize>('large')
const ruleFormRef = ref<FormInstance>()
const ruleForm = ref<RuleForm>({
    id: 0,
    project_id:0,
    user_id:0,
    person_id:0,
    title: '/',
    measure: '/',
    effectiveness:'/',
    start_date: '',
    end_date: '',
    status: 0,
    type:''
})

const onGetData = () => {
    if(!ruleForm.value.id){
        return;
    }
    http.get('/risk/'+ruleForm.value.id).then((response:any)=>{
        if(response.data.data){
            ruleForm.value = response.data.data
        }
    })
}

const props = defineProps<{
    data:any
    type:number
}>()

watch(props,()=>{
    ruleForm.value.id = props.data
    ruleForm.value.user_id = 0
    ruleForm.value.person_id = 0
    ruleForm.value.title = '/',
    ruleForm.value.measure = '/',
    ruleForm.value.effectiveness = '/',
    ruleForm.value.start_date = '',
    ruleForm.value.end_date = '',
    ruleForm.value.type = '',
    ruleForm.value.status =  0,
    type.value = props.type
    onGetData()
    
},{ immediate: true })

</script>
<style scoped>
.el-tab-pane{height: calc(100vh - 25vh);overflow-y: scroll;}
::v-deep .el-form-item .el-form-item__label {
  font-size: 16px; /* 或者你想要的任何大小 */
}
::v-deep .el-tabs__item{font-size: 18px !important;}
</style>
